import api from '../../../utils/apijs';

export default {
  namespaced: true,
  state: {
    bingRen: [],
    nowPage: 1,
  },
  actions: {
    selectBrData(context, obj) {
      return api[obj.name](obj.data).then(data => {
        context.commit('saveBrData', data.data.data);
        return data;
      });
    },
  },
  mutations: {
    saveBrData(state, data) {
      state.bingRen = data;
    },
  },
  getters: {
    maxPage: state => state.bingRen.length / 1,
    nowData: state => state.bingRen.slice((state.nowPage - 1) * 1, state.nowPage * 1),
  },
};
